exports.index = function* (next) {
  this.data = yield this.model.user.find({});
}

exports.create = function* (next) {
  const { data } = this.params;
  this.data = yield this.service.users.create(data);
}

exports.destroy = function* (next) {
  yield this.service.users.remove(this.params.id);
}

exports.show = function* (next) {
 this.data = yield this.service.users.show(this.params.id);
}

exports.update = function* (next) {
  this.data = yield this.service.users.update(this.params);
}

const rule = {
  name: 'string',
  role: {
    type: 'enum',
    values: ['director', 'develop', 'product', 'other'],
  },
  phone: {
    type: 'string',
    required: false,
  },
  email: {
    type: 'email',
    required: false,
  },
};

exports.createRule = rule;
exports.updateRule = rule;
